import threading


class Singleton(object):
    _threading_lock = threading.Lock()


    def __init__(self):
        """
        调用的是子类的__init__  不走此处以下方法不会经过
        """
        pass

    def __new__(cls, *args, **kwargs):
        if not hasattr(cls,'_instance'):
            with cls._threading_lock:
                if not hasattr(cls,'_instance'):
                    cls._instance=super(Singleton,cls).__new__(cls)
                    print('single[%s] new' % cls)
                return cls._instance
        return cls._instance
